<?php

$qtext = "n the symbol <img src=\"QuizImages/topic01/x6C.gif\" align=\"ABSMIDDLE\">, x is";
$qtextabs = "n the symbol <img src=\"http://mysite/QuizImages/topic01/x6C.gif\" align=\"ABSMIDDLE\">, x is";

print "rel: " . correct_imagelinks_question($qtext, 43) . "\n";
print "abs: " . correct_imagelinks_question($qtextabs, 43) . "\n";

function correct_imagelinks_question($text, $courseid){
        $text = html_entity_decode($text);

        $imgfilebase = 'http://dev1/file.php/' . $courseid . '/';
        $text = preg_replace('/(<img ([^>*] )?)src="(?!http:\/\/)([^\/][^"]*)"([^>]*>)/', "\\1 src=\"$imgfilebase\\3\" \\4", $text);

        return $text;
}

?>
